package com.kermel.common.android;

import com.kermel.common.util.StringUtils;

import android.test.AndroidTestCase;
import android.widget.TextView;

public class TextViewUtilsTest extends AndroidTestCase {
    private TextView textViewFixture;
    
    protected void setUp() throws Exception {
        super.setUp();
        
        textViewFixture = new TextView(getContext());
    }

    protected void tearDown() throws Exception {
        textViewFixture = null;
        
        super.tearDown();
    }
    
    public void testThatTruncateTextDoesNotThrowExceptionWhenGivenNullTextView() {
        boolean exceptionCaught = false;
        String text = null;
        
        try {
            TextViewUtils.truncateText(null, text);
        } catch (Exception e) {
            exceptionCaught = true;
        }
        
        assertFalse(exceptionCaught);
    }
    
    public void testThatTruncateTextDoesNotThrowExceptoinWhenGivenNullText() {
        boolean exceptionCaught = false;
        String text = null;
        
        try {
            TextViewUtils.truncateText(textViewFixture, text);
        } catch (Exception e) {
            exceptionCaught = true;
        }
        
        assertFalse(exceptionCaught);
    }
    
    public void testThatTruncateTextReturnsNonNullWhenGivenEmptyText() {
        String text = StringUtils.EMPTY;
        CharSequence result = TextViewUtils.truncateText(textViewFixture, text);
        assertNotNull(result);
    }

}
